#ifndef CREATEMAP_H
#define CREATEMAP_H
#include <QDialog>
#include "../location.h"

class QLabel;
class QLineEdit;
class QPushButton;
class Tree;

class CreateMap : public QDialog
{
	Q_OBJECT
public:
	CreateMap(QWidget *parent = 0);
	~CreateMap();

private slots:
	void placeItemOnMap();
	void placeMapItemOnMap();
	void setItem(const QString &);
	void setMapItem(const QString &);
	
	// Slots for handling locations and map
	void setLocName(const QString &);
	void setMapName(const QString &);
	void newLocation();
	void addLocationToMap();	
	void saveMap();


private:
	
        // All the layout elements
	QLabel *information;
	QLineEdit *itemEdit;
	QLineEdit *mapItemEdit;
	QLineEdit *locationName;
	QLineEdit *mapName;
	QPushButton *placeItem;
	QPushButton *placeMapItem;
	QPushButton *createNewLocation;
	QPushButton *saveLocationToMap;
	QPushButton *saveMapToDisk;

	//Variables to contain user input
	std::string inputItem;
	std::string inputMapItem;
	std::string locName_;
	std::string mapName_;

	// Save which mode the map editor is in
	int mode_;
	
	// Methods to make changes on map
	void placeItemOnMap(int, int);
	void placeMapItemOnMap(int, int);

	// We need a tree to bind the locations to an entire map
	Tree* mapTree;

	// Method for printing error messages
	void errorMessage(std::string);
	bool overwrite(std::string);

public:
	void makeChange(int, int);
	void startMapWindow();

	// SDL window
	class SDL_Surface *screen;
	class DrawMap *drawMap_;
	
	// Location to edit
	class Location *loc_;
	
};

#endif
